package com.huawei;

import java.util.Random;
import java.util.Scanner;

public class Game {
    public static void main(String[] args) {
        int a = 0;//玩家赢的次数
        int b = 0;//平局的次数
        System.out.println("剪刀石头布小游戏正式开始：");
        System.out.println("请输入你要出的数字：（剪刀：1，石头：2，布：3）");
        Scanner sc = new Scanner(System.in);
        for (int i = 1; i <= 5; i++) {
            System.out.println("第" + i + "局");
            int user = Integer.parseInt(sc.next());
            int computer = new Random().nextInt(2) + 1;
1
            if (user == 1) {
                System.out.println("你本次出的是剪刀");
                if (computer == 1) {
                    System.out.println("电脑本次出的是剪刀");
                    System.out.println("打平了");
                    b++;
                }
                else if (computer == 2) {
                    System.out.println("电脑本次出的是石头");
                    System.out.println("你输了");
                }
                else if (computer == 3) {
                    System.out.println("电脑本次出的是布");
                    System.out.println("你赢了");
                    a++;
                }
            }

            else if (user == 2) {
                System.out.println("你本次出的是石头");
                if (computer == 1) {
                    System.out.println("电脑本次出的是剪刀");
                    System.out.println("你赢了");
                    a++;
                }
                else if (computer == 2) {
                    System.out.println("电脑本次出的是石头");
                    System.out.println("打平了");
                    b++;
                }
                else if (computer == 3) {
                    System.out.println("电脑本次出的是布");
                    System.out.println("你输了");
                }
            }

            else if (user == 3) {
                System.out.println("你本次出的是布");
                if (computer == 1) {
                    System.out.println("电脑本次出的是剪刀");
                    System.out.println("你输了");
                }
                else if (computer == 2) {
                    System.out.println("电脑本次出的是石头");
                    System.out.println("你赢了");
                    a++;
                }
                else if (computer == 3) {
                    System.out.println("电脑本次出的是布");
                    System.out.println("打平了");
                    b++;
                }
            }
            System.out.println();
        }

        System.out.println("本次游戏玩家一共赢了"+a+"局 ,打平"+b+"局");
        System.out.println();

        if (a<b){
            System.out.println("最终的结果是电脑赢");
        }

        else if (a>b){
            System.out.println("最终的结果是玩家赢");
        }

        else {
            System.out.println("最终的结果是平局");
        }
    }
}